﻿<!--_meta 作为公共模版分离出去-->
<include file="Public/_meta" />
<!--/meta 作为公共模版分离出去-->

<title>新建网站角色 - 管理员管理</title>
</head>
<style>
ul.group-list {
    margin: auto 5px;list-style: disc outside none;
}
ul.group-list li {
    white-space: nowrap;float: left;
    width: 152px; height: 25px;
    padding: 3px 5px;list-style-type: none;
    list-style-position: outside;border: 0px;margin: 0px;
}
th.title {
    background: #F3F3F3;border-bottom: 1px solid #D7D7D7;font-weight: bold; white-space: nowrap;
}
</style>

<body>
<article class="page-container">
	<form onsubmit="return false;" method="post" class="form form-horizontal" id="roleform">
		<input type="hidden" name="role_id" value="{$detail['role_id']}" />
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>角色名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$detail['name']}" placeholder="" id="name" name="data[name]">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2">描述：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$detail['remark']}" id="remark" name="data[remark]">
			</div>
		</div>

		<!-- <div class="row cl">
			<label class="form-label col-xs-2 col-sm-2">权限列表：</label>
			<div class="formControls col-sm-9">
				<table class="table table-bordered table-striped dataTable" style="margin-bottom: 10px;">
					<tbody id="row-houtai">
						<foreach name="list" item="menu" key="kk" >			
							<tr>
								<td class="title left" style="padding-right:50px;">
									<b>{$menu['name']}：</b>
									<label class="right"><input class="admincheck" type="checkbox" value="1" cka="mod-{$menu['id']}">全选</label>
								</td>
							</tr>
							<tr>
								<td>
									<ul class="group-list">
									<foreach name="menu['sub_menu']" item="vv">
										<li><label><input class="admincheck" type="checkbox" name="right[]" value="{$vv['id']}" <if condition="$vv['enable'] eq 1">checked</if> ck="mod-<{$vv['parent_id']}">{$vv['name']}</label></li>
									</foreach>
									<div class="clear-both"></div>
									</ul>
								</td>
							</tr>
						</foreach>
					</tbody>
					<tfoot>
	                  <tr align="center">
	                    <td>
	                    	<button class="btn btn-default" onclick="resetAdmin()"><i class="Hui-iconfont">&#xe66c;</i>重置</button>
	                    </td>
	                  </tr>
	               </tfoot>
				</table>
			</div>
		</div> -->
		<div class="row cl" style="text-align: center;">
			<button class="btn btn-success radius" style="width: 100px;height: 35px;font-size: 16px;" onclick="roleSubmit()"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<include file="Public/_footer" />
<!--/_footer 作为公共模版分离出去-->

<script type="text/javascript">
	var _index;
	function roleSubmit()
	{
		if($('#name').val() == '' ){
			layer.alert('角色名称不能为空', {icon: 2});
			return false;
		}
		var $form = $("#roleform").serialize();
		// console.log($form);return;
		// action= 
		$.ajax({
			url: "{:U('/admin/admin/roleSave')}",
			type: 'post',
			data: $form,
			beforeSend: function(){
				_index = layer.load(1);
			},
			success: function(res){
				// console.log(res);
				var data = JSON.parse(res);
				if(data.status == 1){
					layer.msg(data.message,{
						icon:1,time:2000
					},function(){
						parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					})
				}else{
					layer.alert(data.message,{icon:2})
				}
			},
			error: function(){
				layer.alert('网络错误，请稍后重试！', {icon: 2});
				return false;
			},
			complete: function(){
				layer.close(_index);
			}
		});
	}

	$(document).ready(function(){
		$(":checkbox[cka]").click(function(){
			var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
			if($(this).is(':checked')){
				$cks.each(function(){$(this).prop("checked",true);});
			}else{
				$cks.each(function(){$(this).removeAttr('checked');});
			}
		});
	});

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>